#include <iostream>
#include <vector>
using namespace std;

// 动态规划
size_t MostAddSub(vector<int>& v){
    vector<int> dp(v.size(), 1);
    size_t sum = 1;
    for(size_t i = 0; i < v.size(); ++i){
        for(size_t j = 0; j < i; ++j){
            if(v[i] > v[j])
                dp[i] = dp[i] > dp[j]+1 ? dp[i] : dp[j]+1;
        }
        sum = sum > dp[i] ? sum : dp[i];
    }
    return sum;
}

int main()
{
	int n;
	while (cin >> n){
		vector<int> v(n);
		for (int i = 0; i < n; ++i)
			cin >> v[i];
        cout << MostAddSub(v) << endl;
    }
	return 0;
}